/* **********************************************************
 * Copyright 2010 Dimitar Vangelovski
 *
 * This file is part of the Gens3 3D Engine.
 * 
 * The Gens3 3D Engine is free software; you can redistribute it and/or
 * modify it under the terms of version 2 of the GNU General Public
 * License as published by the Free Software Foundation.
 * 
 * The Gens3 3D Engine is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 * General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with the Gens3 3D Engine; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
 * 02110-1301, USA
 * **********************************************************/


#include "common.h"
#include "Mesh.h"
#include "MeshTVertList.h"
#include "MeshTFaceList.h"

CMesh::CMesh()
{
	m_nMeshNumVertex = 0;
	m_nMeshNumFaces = 0;
	m_MeshVertexList.clear();
	m_MeshFaceList.clear();
	m_MeshNormals.clear();
	m_pMeshTFaceList = NULL;
	m_pMeshTVertList = NULL;
}

CMesh::CMesh(const CMesh &other)
{
	m_nMeshNumVertex = other.GetMeshNumVertex();
	m_nMeshNumFaces = other.GetMeshNumFaces();
	m_MeshVertexList = other.GetMeshVertexList();
	m_MeshFaceList = other.GetMeshFaceList();
	m_MeshNormals = other.GetMeshNormals();
	m_pMeshTFaceList = other.GetMeshTFaceList();
	m_pMeshTVertList = other.GetMeshTVertList();
}

CMesh::CMesh(int nMeshNumVertex, int nMeshNumFaces)
{
	m_nMeshNumVertex = nMeshNumVertex;
	m_nMeshNumFaces = nMeshNumFaces;
	m_MeshVertexList.resize(m_nMeshNumVertex);
	m_MeshFaceList.resize(m_nMeshNumFaces);
	m_MeshNormals.resize(m_nMeshNumFaces);
}

CMesh::~CMesh()
{
	m_MeshVertexList.clear();
	m_MeshFaceList.clear();
	m_MeshNormals.clear();
	
	if (m_pMeshTVertList)
	{
		delete m_pMeshTVertList;
		m_pMeshTVertList = NULL;
	}

	if (m_pMeshTFaceList)
	{
		delete m_pMeshTFaceList;
		m_pMeshTFaceList = NULL;
	}
}

